package main

import (
	"fmt"
	"sync"
	"time"
)

var wg sync.WaitGroup

func test1() {
	for i := 0; i < 10; i++ {
		fmt.Println("test1()--执行次数：", i)
		time.Sleep(time.Millisecond * 200)
	}
	wg.Done()
}

func test2() {
	defer wg.Done()
	for i := 0; i < 10; i++ {
		fmt.Println("test2()--执行次数：", i)
		time.Sleep(time.Millisecond * 20)
	}
}
func main() {
	wg.Add(1)
	go test1()
	wg.Add(1)
	go test2()
	wg.Wait()
	fmt.Println("主线程结束。。。")
}
